package fem2.gui;

import fem2.gui.pm.HofemPipelineFactory;
import inf.vtk.pm.PipelineCollection;
import inf.vtk.pm.SymbolsPipeline;
import inf.vtk.pm.uiswing.SymbolsPanel;

import java.awt.BorderLayout;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JPanel;

public class SidePanel extends JPanel {

	private static final long serialVersionUID = 1L;

	private PipelineCollection pipelineCollection_;
	private Box mainBox_;

	private SettingsPanel settingsPanel_;

	public SidePanel(PipelineCollection pc) {
		pipelineCollection_ = pc;

		setLayout(new BorderLayout());
		add(getMainBox(), BorderLayout.NORTH);
	}

	public void apply() {
		settingsPanel_.apply();
	}

	private Box getMainBox() {
		if (mainBox_ == null) {
			mainBox_ = new Box(BoxLayout.Y_AXIS);

			settingsPanel_ = new SettingsPanel(pipelineCollection_);

			mainBox_.add(settingsPanel_);
			mainBox_.add(new VisiblePanel(pipelineCollection_));
			mainBox_.add(new SymbolsPanel((SymbolsPipeline) pipelineCollection_
					.getPart(HofemPipelineFactory.PL_SYMBOLS)));
			// mainBox_.add(new ResultsPanel(pipelineCollection_));
		}
		return mainBox_;
	}

	public void update() {
		settingsPanel_.update();
	}

	public int getP() {
		return settingsPanel_.getPP();
	}
}
